package com.sisbibvir.unmsm.controller;

import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import com.sisbibvir.unmsm.dao.JPAUtil;
import com.sisbibvir.unmsm.dao.PostDAO;
import com.sisbibvir.unmsm.entidades.Post;

@ManagedBean(name = "postBean")
@SessionScoped
public class PostController {

	private JPAUtil util;
	private PostDAO po;
	private List<Post> posts;
	private Post post;
	private int id;
	private String detalle;
	private int nroPost;
	
	public void agregar() {
		util = new JPAUtil();
		po = new PostDAO(util.getEntityManager());
		post = new Post();
	}
	
	public List<Post> getPosts() {
		util = new JPAUtil();
		po = new PostDAO(util.getEntityManager());
		posts = po.listarTodos();
		util = null;
		return posts;
	}
	
	public void setPosts(List<Post> posts) {
		this.posts = posts;
	}

	public Post getPost() {
		return post;
	}

	public void setPost(Post post) {
		this.post = post;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getDetalle() {
		return detalle;
	}

	public void setDetalle(String detalle) {
		this.detalle = detalle;
	}

	public int getNroPost() {
		return nroPost;
	}

	public void setNroPost(int nroPost) {
		this.nroPost = nroPost;
	}

}
